package com.neuedu.view;

import java.awt.EventQueue;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.GridLayout;


public class LookingviewFrame extends JFrame {

	
	private JTextField gdnameField;
	private JTextField producttimeField;
	private JTextField textField_2;
	private JTextField textField_1;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					LookingviewFrame frame = new LookingviewFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public LookingviewFrame() {
		setTitle("浏览商品");
		//设置窗体位置与大小
		setBounds(100, 100, 450, 300);
		//设置关闭操作的事件
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//固定大小
		setSize(700,800);
		//设置窗口的位置为居中显示
		setLocationRelativeTo(null);
		getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
		//第一布局：
		JPanel numberone = new JPanel();
		getContentPane().add(numberone, BorderLayout.NORTH);
		GridBagLayout gbl_panel = new GridBagLayout();
		numberone.setLayout(gbl_panel);
		
		JLabel gdnameLabel = new JLabel("商品名称");
		GridBagConstraints gbc_gdnameLabel = new GridBagConstraints();
		gbc_gdnameLabel.anchor = GridBagConstraints.EAST;
		gbc_gdnameLabel.insets = new Insets(5, 5, 10, 5);
		gbc_gdnameLabel.gridx = 0;
		gbc_gdnameLabel.gridy = 0;
		numberone.add(gdnameLabel, gbc_gdnameLabel);
		
		gdnameField = new JTextField();
		GridBagConstraints gbc_gdnameField = new GridBagConstraints();
		gbc_gdnameField.insets = new Insets(5, 5, 10, 10);
		gbc_gdnameField.fill = GridBagConstraints.HORIZONTAL;
		gbc_gdnameField.gridx = 1;
		gbc_gdnameField.gridy = 0;
		numberone.add(gdnameField, gbc_gdnameField);
		gdnameField.setColumns(5);
		
		JLabel producttimeLabel = new JLabel("生产日期");
		GridBagConstraints gbc_producttimeLabel = new GridBagConstraints();
		gbc_producttimeLabel.anchor = GridBagConstraints.EAST;
		gbc_producttimeLabel.insets = new Insets(5, 5, 10, 5);
		gbc_producttimeLabel.gridx = 3;
		gbc_producttimeLabel.gridy = 0;
		numberone.add(producttimeLabel, gbc_producttimeLabel);
		
		producttimeField = new JTextField();
		GridBagConstraints gbc_producttimeField = new GridBagConstraints();
		gbc_producttimeField.insets = new Insets(5, 5, 10, 10);
		gbc_producttimeField.fill = GridBagConstraints.HORIZONTAL;
		gbc_producttimeField.gridx = 4;
		gbc_producttimeField.gridy = 0;
		numberone.add(producttimeField, gbc_producttimeField);
		producttimeField.setColumns(10);
		
		JLabel lblNewLabel_2 = new JLabel("商品类别");
		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
		gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_2.insets = new Insets(5, 5, 10, 5);
		gbc_lblNewLabel_2.gridx = 5;
		gbc_lblNewLabel_2.gridy = 0;
		numberone.add(lblNewLabel_2, gbc_lblNewLabel_2);
		
		textField_2 = new JTextField();
		GridBagConstraints gbc_textField_2 = new GridBagConstraints();
		gbc_textField_2.insets = new Insets(5, 5, 10, 10);
		gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_2.gridx = 6;
		gbc_textField_2.gridy = 0;
		numberone.add(textField_2, gbc_textField_2);
		textField_2.setColumns(10);
		
		JButton searchButton = new JButton("查询");
		searchButton.setIcon(new ImageIcon("./images/search.png"));
		GridBagConstraints gbc_searchButton = new GridBagConstraints();
		gbc_searchButton.insets = new Insets(5, 5, 10, 0);
		gbc_searchButton.gridx = 9;
		gbc_searchButton.gridy = 0;
		numberone.add(searchButton, gbc_searchButton);
		
		
		//第二页面布局：
		JScrollPane numbertwo = new JScrollPane();
		getContentPane().add(numbertwo, BorderLayout.SOUTH);
		String[] columnNames = {"编号","商品名称","生产日期","商品价格","商品描述","商品类别"};
		Object[][] data= {{"2","华为手机","2023/5/9","2334.0","5G手机就是好","手机类"},
				{"4","芒果","2023/6/10","12.011","水果新上市","水果类"},
				{"5","thinkpad","2023/3/12","4358.0","电脑","电脑类"},
				{"6","雪糕","2023/6/22","2.5","好吃","食品类"},
				{"7","科技书","2022/12/11","15.3","益智","书本类"}};
		
		DefaultTableModel model=new DefaultTableModel(data,columnNames);
		JTable table=new JTable(model);
		JScrollPane tablePanel=new JScrollPane(table);
		getContentPane().add(tablePanel);
		
		
		
		//第三页面布局：
		JPanel numberthree = new JPanel();
		getContentPane().add(numberthree, BorderLayout.WEST);
		GridBagLayout gbl_numberthree = new GridBagLayout();
		gbl_numberthree.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0};
		gbl_numberthree.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
		numberthree.setLayout(gbl_numberthree);
		
		JLabel lblNewLabel = new JLabel("编号");
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 1;
		gbc_lblNewLabel.gridy = 0;
		numberthree.add(lblNewLabel, gbc_lblNewLabel);
		
		textField_1 = new JTextField();
		GridBagConstraints gbc_textField_1 = new GridBagConstraints();
		gbc_textField_1.insets = new Insets(0, 0, 5, 5);
		gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_1.gridx = 2;
		gbc_textField_1.gridy = 0;
		numberthree.add(textField_1, gbc_textField_1);
		textField_1.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("商品名称");
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_1.gridx = 3;
		gbc_lblNewLabel_1.gridy = 0;
		numberthree.add(lblNewLabel_1, gbc_lblNewLabel_1);
		
		textField_3 = new JTextField();
		GridBagConstraints gbc_textField_3 = new GridBagConstraints();
		gbc_textField_3.insets = new Insets(0, 0, 5, 5);
		gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_3.gridx = 4;
		gbc_textField_3.gridy = 0;
		numberthree.add(textField_3, gbc_textField_3);
		textField_3.setColumns(10);
		
		JLabel lblNewLabel_5 = new JLabel("商品描述");
		GridBagConstraints gbc_lblNewLabel_5 = new GridBagConstraints();
		gbc_lblNewLabel_5.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_5.gridx = 8;
		gbc_lblNewLabel_5.gridy = 0;
		numberthree.add(lblNewLabel_5, gbc_lblNewLabel_5);
		
		JTextArea textArea = new JTextArea();
		GridBagConstraints gbc_textArea = new GridBagConstraints();
		gbc_textArea.insets = new Insets(0, 0, 5, 0);
		gbc_textArea.gridwidth = 3;
		gbc_textArea.gridheight = 3;
		gbc_textArea.fill = GridBagConstraints.BOTH;
		gbc_textArea.gridx = 9;
		gbc_textArea.gridy = 0;
		numberthree.add(textArea, gbc_textArea);
		
		JLabel lblNewLabel_3 = new JLabel("价格");
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
		gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_3.gridx = 1;
		gbc_lblNewLabel_3.gridy = 2;
		numberthree.add(lblNewLabel_3, gbc_lblNewLabel_3);
		
		textField_4 = new JTextField();
		GridBagConstraints gbc_textField_4 = new GridBagConstraints();
		gbc_textField_4.insets = new Insets(0, 0, 5, 5);
		gbc_textField_4.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_4.gridx = 2;
		gbc_textField_4.gridy = 2;
		numberthree.add(textField_4, gbc_textField_4);
		textField_4.setColumns(10);
		
		JLabel lblNewLabel_4 = new JLabel("生产日期");
		GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
		gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_4.gridx = 3;
		gbc_lblNewLabel_4.gridy = 2;
		numberthree.add(lblNewLabel_4, gbc_lblNewLabel_4);
		
		textField_5 = new JTextField();
		GridBagConstraints gbc_textField_5 = new GridBagConstraints();
		gbc_textField_5.insets = new Insets(0, 0, 5, 5);
		gbc_textField_5.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_5.gridx = 4;
		gbc_textField_5.gridy = 2;
		numberthree.add(textField_5, gbc_textField_5);
		textField_5.setColumns(10);
		
		JLabel lblNewLabel_6 = new JLabel("商品类别");
		GridBagConstraints gbc_lblNewLabel_6 = new GridBagConstraints();
		gbc_lblNewLabel_6.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_6.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_6.gridx = 6;
		gbc_lblNewLabel_6.gridy = 2;
		numberthree.add(lblNewLabel_6, gbc_lblNewLabel_6);
		
		textField_6 = new JTextField();
		GridBagConstraints gbc_textField_6 = new GridBagConstraints();
		gbc_textField_6.insets = new Insets(0, 0, 5, 5);
		gbc_textField_6.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_6.gridx = 7;
		gbc_textField_6.gridy = 2;
		numberthree.add(textField_6, gbc_textField_6);
		textField_6.setColumns(10);
		
		JButton btnNewButton = new JButton("把该商品加入购物车");
		GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
		gbc_btnNewButton.gridx = 10;
		gbc_btnNewButton.gridy = 3;
		numberthree.add(btnNewButton, gbc_btnNewButton);
		
		
		
		//第四页面布局：
		String[] column = {"编号","商品名称","生产日期","商品价格","商品描述","商品类别"};
		Object[][] number= {{"16","华为手机","2023/5/9","2334.0","5G手机就是好","手机类"},
				{"17","雪糕","2023/6/22","2.5","好吃","食品类"},
				{"18","芒果","2023/6/10","12.011","水果新上市","水果类"}};
		//创建
		DefaultTableModel boder=new DefaultTableModel(number,column);
		JTable table1=new JTable(boder);
		getContentPane().add(table1);
		JScrollPane aleadyPanel = new JScrollPane(table1);
		getContentPane().add(aleadyPanel);
		
		//第五页面布局:
		JPanel panel = new JPanel();
		getContentPane().add(panel);
		
		JButton btnNewButton_1 = new JButton("删除该已选商品");
		btnNewButton_1.setIcon(new ImageIcon("./images/delete.png"));
		panel.add(btnNewButton_1);
		
		JButton btnNewButton_3 = new JButton("结算");
		btnNewButton_3.setIcon(new ImageIcon("./images/money.png"));
		panel.add(btnNewButton_3);
		
		
		
		
		
		
		
		
	}

}
